#include "cairodock.h"
#include <QVBoxLayout>
#include <QPushButton>
#include <QPainter>

CairoDock::CairoDock(QList<CairoIcon*>& elements)
{
    this->createMenu(elements);
    this->setMouseTracking(true);
    this->setMaximumHeight(500);
    setAttribute(Qt::WA_OpaquePaintEvent, false);
    setAttribute(Qt::WA_TranslucentBackground, true);
    setAttribute(Qt::WA_QuitOnClose);
    setWindowFlags(Qt::FramelessWindowHint);
}
void CairoDock::createMenu(QList<CairoIcon*>& elements){
    QHBoxLayout *layout= new QHBoxLayout();
    CairoIcon * icon;
    foreach(icon,elements)
        layout->addWidget(icon);
    this->setLayout(layout);
}

void CairoDock::paintEvent ( QPaintEvent *) {
    QPainter paint(this);
    this->setAttribute(Qt::WA_NoSystemBackground,true);
    QPolygon pol;
    pol<<QPoint(0,this->height());
    pol<<QPoint(this->width(),this->height());
    pol<<QPoint(this->width()*9/10,this->height()*6/10);
    pol<<QPoint(width()*1/10,this->height()*6/10);
    paint.setBrush(QBrush(QLinearGradient(this->width()/2,0,this->width()/2,this->height())));
    paint.drawPolygon(pol);
}



